<?php

require_once BaseUtil::getModulePath ( "base" ) . '/forms/BaseForm.php';
require_once BaseUtil::getModulePath ( "base" ) . '/validate/Unique.php';
require_once BaseUtil::getModulePath ( "metadata" ) . '/constants/MetadataConstant.php';

class GroupForm extends BaseForm {
	
	public function __construct($data=array()) {
		
		parent::__construct ();
		
		$this->setAction ( HttpUtil::getUrl ( "set", "subaddgroup" ) );
		//element code
		$id = new Zend_Form_Element_Hidden ( "id" );
		
		$validUniqueCode = new MyValid_Unique ( );
		
		//element title
		$title = new Zend_Form_Element_Text ( "title" );
		$title->setLabel ( $this->translate->_ ( 'title' ) );
		$title->addFilter ( "StringTrim" );
		$title->setRequired ( true );
		
		
		//sort_order
        $sortOrder = new Zend_Form_Element_Text("sort_order");
        $sortOrder->setLabel($this->translate->_('sortOrder'));
        $sortOrder->addFilter("Alnum");
        
		if(!empty($data)){
			$id->setValue($data->id);
			$title->setValue($data->title);
			$this->setAction ( HttpUtil::getUrl ( "set", "subeditgroup" ) );
			$sortOrder->setValue($data->sort_order);
			
		}
		
		$this->addElements ( array ($id, $title,$sortOrder ) );
		
		$this->setElementDecorators ( array ('ViewHelper', array (array ('div' => 'HtmlTag' ), array ('tag' => 'div', "class" => "form_element" ) ) ) );
	}
}